var n = 0, flag = true, JSONData = "", Mess = "";
var appdata = "", metxt = "", metu = "";
var plxx = new Array();
var newsbox = $(".datalist");
/*初始化*/
var counter = 1;
/*计数器*/
var pageStart = 0;
/*offset*/
var pageSize = 1;
/*size*/

/*首次加载*/
getData(pageStart, pageSize);

/*监听加载更多*/
$(document).on('click', '.js-load-more', function () {
    counter++;
    pageStart = counter * pageSize;

    getData(pageStart, pageSize);
});

function getData(offset, size) {
    $.ajax({
        url: "messlist",
        type: "POST",
        dataType: "JSON",
        data: {"form": counter},
        success: function (data) {


            /*使用for循环模拟SQL里的limit(offset,size)*/
            console.log(data)
            Mess = data.Page.pageList;
            metu = data.Img;
            for (var o = 0; o < Mess.length; o++) {

                appdata += " <div class='aui-service-circle' style='width:165px;'><span>" + Mess[o].informationDate + "</span> </div><div class='aui-service-list'><h3>" + Mess[o].informationTitle + "</h3><a href='javascript:;' class='aui-news-item'><div class='aui-news-item-hd'><img src='/" + metu + "' alt=''></div><div class='aui-news-item-bd'><p>" + Mess[o].informationText + "</p></div></a></div>"
                newsbox.html("")
                newsbox.append(appdata);
            }
            if (Mess.length == 0) {

                appdata = "<img style='position: relative;top: 90px;left: -60px;' src='/images/kong.png'>";
                newsbox.html("")
                newsbox.append(appdata);
            }

            /*隐藏more按钮*/
            if (data.Page.hasNextPage == false) {
                $(".js-load-more").hide();
            } else {
                $(".js-load-more").show();
            }
        },
        error: function (xhr, type) {
            console.log("操作异常")
        }
    });
}

$(".goback").click(function () {
    location.href = "doindex"
})
